<?php
/**
 * 商城系统配置模型层
 * 
 * @copyright 	Copyright (c) 2011 thinkapk.com All rights reserved.
 * @package 	ThinkAPK_Model
 * @link 		http://www.thinkapk.com/
 * @author 		richie <richbossman@163.com>
 * @version 	$Id: ShopConfigModel.class.php 7600 2011-06-03 03:36:36Z yemusheng $
 * 
 */
class ShopConfigModel extends CommonModel {
	
	/**
	 * 取得配置值
	 *
	 * @return array
	 */
	public function get(){
		$arr = $this->where('parent_id>0 AND parent_id<>940')->getField('code,value');
		$arr ['integral_scale'] = floatval ( $arr ['integral_scale'] );
		$arr ['integral_percent'] = floatval ( $arr ['integral_percent'] );
		$arr ['cache_time'] = intval ( $arr ['cache_time'] );
		$arr ['thumb_width'] = intval ( $arr ['thumb_width'] );
		$arr ['thumb_height'] = intval ( $arr ['thumb_height'] );
		$arr ['image_width'] = intval ( $arr ['image_width'] );
		$arr ['image_height'] = intval ( $arr ['image_height'] );
		$arr ['best_number'] = ! empty ( $arr ['best_number'] ) && intval ( $arr ['best_number'] ) > 0 ? intval ( $arr ['best_number'] ) : 3;
		$arr ['new_number'] = ! empty ( $arr ['new_number'] ) && intval ( $arr ['new_number'] ) > 0 ? intval ( $arr ['new_number'] ) : 3;
		$arr ['hot_number'] = ! empty ( $arr ['hot_number'] ) && intval ( $arr ['hot_number'] ) > 0 ? intval ( $arr ['hot_number'] ) : 3;
		$arr ['promote_number'] = ! empty ( $arr ['promote_number'] ) && intval ( $arr ['promote_number'] ) > 0 ? intval ( $arr ['promote_number'] ) : 3;
		$arr ['top_number'] = intval ( $arr ['top_number'] ) > 0 ? intval ( $arr ['top_number'] ) : 10;
		$arr ['history_number'] = intval ( $arr ['history_number'] ) > 0 ? intval ( $arr ['history_number'] ) : 5;
		$arr ['comments_number'] = intval ( $arr ['comments_number'] ) > 0 ? intval ( $arr ['comments_number'] ) : 5;
		$arr ['article_number'] = intval ( $arr ['article_number'] ) > 0 ? intval ( $arr ['article_number'] ) : 5;
		$arr ['page_size'] = intval ( $arr ['page_size'] ) > 0 ? intval ( $arr ['page_size'] ) : 10;
		$arr ['bought_goods'] = intval ( $arr ['bought_goods'] );
		$arr ['goods_name_length'] = intval ( $arr ['goods_name_length'] );
		$arr ['top10_time'] = intval ( $arr ['top10_time'] );
		$arr ['goods_gallery_number'] = intval ( $arr ['goods_gallery_number'] ) ? intval ( $arr ['goods_gallery_number'] ) : 5;
		return $arr;
	}
	
	/*
	 *取得商城的单个帮助信息
	 * @param string  $code		code值
	*/
	public function getConfigInfo($code){
		$value=$this->where("code='{$code}'")->getField('value');
		return $value;
	}
	
}
?>